package algorithm.graph;

/**
 * 带权无向图
 * 图的邻接矩阵表示，采用顺序存储结构顶点集合和边集合，存在因数组容量不够导致数据溢出问题
 * AdjMatrixGraph采用顺序表存储顶点集合，已解决数据溢出问题
 */
public class WeightUndiGraph3 {
    public static void main(String[] args) {
        String[] vertices = {"A","B","C","D","E"}; //带权无向图G3的顶点集合
        //G3的边集合
        Edge edges[] = {
                new Edge(0,1,5),
                new Edge(0,3,2),
                new Edge(1,0,5),
                new Edge(1,2,7),
                new Edge(1,3,6),
                new Edge(2,1,7),
                new Edge(2,3,8),
                new Edge(2,4,3),
                new Edge(3,0,2),
                new Edge(3,1,6),
                new Edge(3,2,8),
                new Edge(3,4,9),
                new Edge(4,2,3),
                new Edge(4,3,9)
        };
        AdjMatrixGraph<String> graph = new AdjMatrixGraph<String>(vertices,edges);
        System.out.println("带权无向图G3,"+graph.toString());
        System.out.println("删除顶点V2,"+graph.removerVertex(2)+" ");
        System.out.println("删除边(v2,v3),"+(graph.removeEdge(2,3) && graph.removeEdge(3,2)));
        System.out.println(graph.toString());
    }
}
